package com.sharer.last.base.enums;

import com.sharer.last.base.interfaces.BaseExceptionCode;
import lombok.Getter;

/**
 * 全局错误返回码
 *
 * @ClassName ExceptionCode
 * @Author WangJin
 * @Date 2023/4/27 17:49
 * @Description
 * @Version 1.0
 */
@Getter
public enum ExceptionCode implements BaseExceptionCode {
    /**
     * *系统类
     */
    OK(0, "success"),
    SUCCESS(0, "操作成功"),
    ERROR(-1, "系统错误"),
    FAIL(101, "系统异常"),
    BUSINESS_FAIL(102, "业务异常"),
    /**
     * 请求类
     */
    BAD_REQUEST(400, "400错误"),
    NOT_FOUND(404, "404错误"),
    METHOD_NOT_ALLOWED(405, "请求方法不支持"),
    MEDIA_TYPE_NOT_ACCEPTABLE(406, "media_type_not_acceptable"),
    TOO_MANY_REQUEST(407, "too_many_request"),
    CHECK_PASSWORD_FAIL(403,"校验失败"),

    // 参数类
    /**
     * 参数异常
     */
    PARAMS_ERROR(10001, "参数异常"),
    /**
     * 参数验证有误
     */
    VALIDATION_ERROR(10002, "参数验证有误"),
    /**
     * token不能为空
     */
    TOKEN_IS_EMPTY(10003, "token不能为空"),
    /**
     * 密码错误
     */
    PASSWORD_IS_ERROR(10004, "密码错误"),
    ;
    private int code;

    private String msg;

    private String prefix;

    ExceptionCode(int code, String message) {
        this.code = code;
        this.msg = message;
    }

    ExceptionCode(int code, String message, String prefix) {
        this.code = code;
        this.msg = message;
        this.prefix = prefix;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }


    public void setCode(int code) {
        this.code = code;
    }

    public void setPrefix(String prefix) {
        this.prefix = prefix;
    }
//
//    public String getExtra(String... args) {
//        if (this.extra != null) {
//            return String.format(this.extra, args);
//        } else {
//            return this.msg;
//        }
//    }
}
